/**
 * Created by Chris on 14-2-15.
 */
define(['text!login/menu.html', 'login/swipe'],
    function(viewTemplate) {
        return Piece.View.extend({
            id: 'login_logined',
            events: {
                "click .home": "homeClick",
                "click #submit": "phonecanclebtClick",
       
            },
            render: function() {
                $(this.el).html(viewTemplate);

                Piece.View.prototype.render.call(this);
                return this;
            },
            onShow: function() {

                // $("#position").append("<li></li>");
                //  $("#position").children("li:nth-child(1)").addClass("on");

                var elem = document.getElementById('mySwipe');
                window.mySwipe = Swipe(elem, {
                    // startSlide: 4,
                    // auto: 3000,
                    // continuous: true,
                    // disableScroll: true,
                    // stopPropagation: true,
                    callback: function(index, element) {
                        var whichPage = index + 1;
                        $("#position").children("li").removeClass("on");
                        $("#position").children("li:nth-child(" + whichPage + ")").addClass("on");

                        console.info(index + "---");
                    },

                    transitionEnd: function(index, element) {
                        console.info(index + "===---");

                    }
                });

                //write your business logic here :)
            },

            homeClick: function(e) {
                var el = $(e.currentTarget);


                var id = $(el).attr('state');


                console.info(id + "===");
                if (id == "home5") {


                    this.container.navigateForResult('/service/index', {
                        trigger: true
                    }, 'login/menu', this.onGotResult);
                } else if (id == "home6") {

                    $("#entryBlock").show();

                }

            },
            phonecanclebtClick: function(e) {


                var me = this;
                var el = e.currentTarget;
                var state = $(el).attr('state');

                $("#entryBlock").hide();




                    var newphone = $("#newphone").val();


                this.container.navigateForResult('/evaluate/appraise', {
                    trigger: true
                }, 'login/menu', this.onGotResult);

            },


        }); //view define

    });